<?php session_start(); require_once('../connections/con_gl.php'); ?>
<?php
$act = $_GET[act];
$url = "index.php?component=transaksicheckinout";
$ope = $_POST['open'];

/* Validasi */
if (trim($_POST['nopolisi']) == '') {
	$error[] = '- No. Polisi harus diisi';
}

/*End validasi */
if (isset($error)) {
	echo "<img src=\"images/alert.png\" width=\"16\" align=\"left\"/>&nbsp;&nbsp;<b style=\"color:red;\">Error : </b> <br />".implode("<br />", $error);
}else{
	if($act =='add') {
	mysql_query("delete from gl_transaksicheckinout where noreferensi = '$_POST[noreferensi]' and unit_id='$_POST[unit_id]'",$con_gl) or die (mysql_error());
	$query = "INSERT INTO gl_transaksicheckinout (id, unit_id,nopolisi, noreferensi, tglcheckin,tglcheckout, jamcheckin,jamcheckout, checkin, checkout, kondmesin1, kondmesin2, kondrem1, kondrem2, kondkopling1, kondkopling2, kondban1, kondban2, kondac1, kondac2, kondsen1, kondsen2, kondlampu1, kondlampu2, kondlampurem1, kondlampurem2, kondaccu1, kondaccu2, kondrad1, kondrad2, kondolimesin1, kondolimesin2, kondolistreering1, kondolistreering2, kondinterior1, kondinterior2, kondbodi1, kondbodi2, bancad1, bancad2, dongkrak1, dongkrak2, kunciroda1, kunciroda2, radio1,radio2, karpet1, karpet2, doproda1, doproda2, pematikapi1, pematikapi2, segitiga1, segitiga2, kotakobat1, kotakobat2, stnk1, stnk2, kuncipintu1, kuncipintu2, 	speedometerout, speedometerin, tglnextcheckin, bodidepan1, bodidepan2, bodiatas1, bodiatas2, bodibelakang1, bodibelakang2, sampingkiri1, sampingkiri2, sampingkanan1, sampingkanan2,checkout_by,checkin_by) VALUES (NULL, '$_POST[unit_id]','$_POST[nopolisi]', '$_POST[noreferensi]', '$_POST[tglcheckin]','$_POST[tglcheckout]', '$_POST[jamcheckin]','$_POST[jamcheckout]', '$_POST[checkin]', '$_POST[checkout]','$_POST[RadioGroup1]', '$_POST[RadioGroup2]', '$_POST[RadioGroup3]', '$_POST[RadioGroup4]', '$_POST[RadioGroup5]', '$_POST[RadioGroup6]', '$_POST[RadioGroup7]', '$_POST[RadioGroup8]', '$_POST[RadioGroup9]', '$_POST[RadioGroup10]', '$_POST[RadioGroup11]', '$_POST[RadioGroup12]', '$_POST[RadioGroup13]', '$_POST[RadioGroup14]', '$_POST[RadioGroup15]', '$_POST[RadioGroup16]', '$_POST[RadioGroup17]', '$_POST[RadioGroup18]', '$_POST[RadioGroup19]', '$_POST[RadioGroup20]', '$_POST[RadioGroup21]', '$_POST[RadioGroup22]', '$_POST[RadioGroup23]', '$_POST[RadioGroup24]', '$_POST[RadioGroup25]', '$_POST[RadioGroup26]', '$_POST[RadioGroup27]', '$_POST[RadioGroup28]', '$_POST[RadioGroup29]', '$_POST[RadioGroup30]', '$_POST[RadioGroup31]', '$_POST[RadioGroup32]', '$_POST[RadioGroup33]', '$_POST[RadioGroup34]', '$_POST[RadioGroup35]', '$_POST[RadioGroup36]', '$_POST[RadioGroup37]', '$_POST[RadioGroup38]', '$_POST[RadioGroup39]', '$_POST[RadioGroup40]', '$_POST[RadioGroup41]', '$_POST[RadioGroup42]', '$_POST[RadioGroup43]', '$_POST[RadioGroup44]', '$_POST[RadioGroup45]', '$_POST[RadioGroup46]', '$_POST[RadioGroup47]', '$_POST[RadioGroup48]', '$_POST[RadioGroup51]', '$_POST[RadioGroup52]', '$_POST[speedometerout]', '$_POST[speedometerin]', '$_POST[tglnextcheckin]', '$_POST[bodidepan1]', '$_POST[bodidepan2]', '$_POST[bodiatas1]', '$_POST[bodiatas2]', '$_POST[bodibelakang1]', '$_POST[bodibelakang2]', '$_POST[sampingkiri1]', '$_POST[sampingkiri2]', '$_POST[sampingkanan1]', '$_POST[sampingkanan2]','$_POST[checkout_by]','$_POST[checkin_by]')";
	}else if($act=='edit'){
	$query ="UPDATE gl_transaksicheckinout SET nopolisi='$_POST[nopolisi]', noreferensi='$_POST[noreferensi]', tglcheckin='$_POST[tglcheckin]',tglcheckout='$_POST[tglcheckout]', jamcheckin='$_POST[jamcheckin]', jamcheckout='$_POST[jamcheckout]',checkin='$_POST[checkin]',checkout='$_POST[checkout]', kondmesin1='$_POST[RadioGroup1]', kondmesin2='$_POST[RadioGroup2]', kondrem1='$_POST[RadioGroup3]', kondrem2='$_POST[RadioGroup4]', kondkopling1='$_POST[RadioGroup5]', kondkopling2='$_POST[RadioGroup6]', kondban1='$_POST[RadioGroup7]', kondban2='$_POST[RadioGroup8]', kondac1='$_POST[RadioGroup9]', kondac2='$_POST[RadioGroup10]', kondsen1='$_POST[RadioGroup11]', kondsen2='$_POST[RadioGroup12]', kondlampu1='$_POST[RadioGroup13]', kondlampu2='$_POST[RadioGroup14]', kondlampurem1='$_POST[RadioGroup15]', kondlampurem2='$_POST[RadioGroup16]', kondaccu1='$_POST[RadioGroup17]', kondaccu2='$_POST[RadioGroup18]', kondrad1='$_POST[RadioGroup19]', kondrad2='$_POST[RadioGroup20]', kondolimesin1='$_POST[RadioGroup21]', kondolimesin2='$_POST[RadioGroup22]', kondolistreering1='$_POST[RadioGroup23]', kondolistreering2='$_POST[RadioGroup24]', kondinterior1='$_POST[RadioGroup25]', kondinterior2='$_POST[RadioGroup26]', kondbodi1='$_POST[RadioGroup27]', kondbodi2='$_POST[RadioGroup28]', bancad1='$_POST[RadioGroup29]', bancad2='$_POST[RadioGroup30]', dongkrak1='$_POST[RadioGroup31]', dongkrak2='$_POST[RadioGroup32]', kunciroda1='$_POST[RadioGroup33]', kunciroda2='$_POST[RadioGroup34]', radio1='$_POST[RadioGroup35]',radio2='$_POST[RadioGroup36]', karpet1='$_POST[RadioGroup37]', karpet2='$_POST[RadioGroup38]', doproda1='$_POST[RadioGroup39]', doproda2='$_POST[RadioGroup40]', pematikapi1='$_POST[RadioGroup41]', pematikapi2='$_POST[RadioGroup42]', segitiga1='$_POST[RadioGroup43]', segitiga2='$_POST[RadioGroup44]', kotakobat1='$_POST[RadioGroup45]', kotakobat2='$_POST[RadioGroup46]', stnk1='$_POST[RadioGroup47]', stnk2='$_POST[RadioGroup48]',kuncipintu1='$_POST[RadioGroup51]', kuncipintu2='$_POST[RadioGroup52]', speedometerout='$_POST[speedometerout]', speedometerin='$_POST[speedometerin]', tglnextcheckin='$_POST[tglnextcheckin]', bodidepan1='$_POST[outbodydepan]', bodidepan2='$_POST[inbodydepan]', bodiatas1='$_POST[outbodyatas]', bodiatas2='$_POST[inbodyatas]', bodibelakang1='$_POST[outbodybelakang]', bodibelakang2='$_POST[inbodybelakang]', sampingkiri1='$_POST[outbodysampingki]', sampingkiri2='$_POST[inbodysampingki]', sampingkanan1='$_POST[outbodysampingka]', sampingkanan2='$_POST[inbodysampingka]' WHERE id='$_POST[id]' and unit_id='$_POST[unit_id]'"; //echo $query;
	}else{
	$query = "delete from gl_transaksicheckinout where id='$_POST[id]'";
	} //echo $query;
	mysql_select_db($database_con_gl, $con_gl);
	$runquery = mysql_query($query, $con_gl) or die (mysql_error());
	if($runquery) {
		echo "<img src=\"images/ok.png\" align=\"left\" width=\"16\">&nbsp;&nbsp;Data berhasil ";if($act=='add' OR $act=='edit') { echo "disimpan";}else{ echo "dihapus"; } echo " ...";
	}else{
		echo "<img src=\"images/alert.png\" align=\"left\" width=\"16\"> Data gagal disimpan !!!";
	}
}
?>
<?php if($runquery AND $ope=='window') { ?>
	<script type="text/javascript">window.opener.sendRespondKelompok(); window.opener.location.reload(); self.close(2000);</script>
<?php }else if($runquery AND $ope==''){ ?>
	<script type="text/javascript">setTimeout("location.href='<?php echo $url;?>'", 2000);</script>
<?php } ?>
<script>window.opener.location.reload(); window.close();</script>